package com.ibeeking.found.msg.rest.controller.v1;

import com.ibeeking.found.msg.rest.service.IMsgBindConfigService;
import com.ibeeking.found.msg.service.common.param.MsgBindConfigParam;
import com.ibeeking.found.msg.service.common.query.MsgBindConfigQuery;
import com.ibeeking.found.msg.service.common.vo.MsgBindConfigVO;
import com.ibeeking.found.msg.service.common.vo.MsgBindConfigViewVO;
import com.ibeeking.nematos.constants.enums.LogClassifyEnum;
import com.ibeeking.nematos.constants.enums.LogSourceEnum;
import com.ibeeking.nematos.constants.enums.OperateLogTypeEnum;
import com.ibeeking.nematos.log.annotation.Log;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @ClassName MsgBaseInfoController控制器
 * @Description 消息基本信息配置
 * @Author ibeeking
 * @Date 2022-01-05 14:41
 **/
@RestController
@RequestMapping("/msg/msgBindConfig/v1")
public class MsgBindConfigController {

    @Resource
    private IMsgBindConfigService msgBindConfigServiceImpl;

    @Log(logType = OperateLogTypeEnum.QUERY, describe = "查询消息基本信息配置列表")
    @PostMapping(value = "/list")
    public List<MsgBindConfigVO> list(@RequestBody MsgBindConfigQuery query) {
        return msgBindConfigServiceImpl.list(query);
    }

    @Log(logType = OperateLogTypeEnum.QUERY, describe = "查询消息基本信息配置")
    @GetMapping(value = "/view/{id}")
    public MsgBindConfigViewVO view(@PathVariable("id") Long id) {
        return msgBindConfigServiceImpl.view(id);
    }

    @Log(logType = OperateLogTypeEnum.MODIFY, describe = "保存消息基本信息配置")
    @PostMapping(value = "/save")
    public Boolean save(@RequestBody @Validated MsgBindConfigParam param) {
        return msgBindConfigServiceImpl.save(param);
    }

    @Log(logSource = LogSourceEnum.TENANT_LOG,logClassify = LogClassifyEnum.OPERATION_LOG,logType = OperateLogTypeEnum.MODIFY, describe = "消息基本信息启用/禁用")
    @PostMapping(value = "/changeStatus/{id}/{type}/{status}")
    public Boolean changeTemplatePublishStatus( @PathVariable("id") Long id, @PathVariable("type") Integer type, @PathVariable("status") Integer status) {
        return msgBindConfigServiceImpl.changeStatus(id, type, status);
    }

}
